package JavaUtils.uitl.math;

import java.util.Random;

public class VectorUnit {
	private static Random rnd = new Random();
	
	/**
	 * 获取圆内随机位置
	 * @param radius	随机半径
	 * @return
	 */
	public static Vector3f getRandomPosition(float radius){
		//随机距离
		float distance = rnd.nextInt((int)(radius * 100)) / 100f;
		//随机角度
		Vector3f pz = new Vector3f(rnd.nextInt(20) / 10f - 1f, 0, rnd.nextInt(20) / 10f - 1f);
		Vector3f position = pz.normalizeLocal().mult(distance);
        return position;
	}
	
	/**
	 * 获取圆内随机位置
	 * @param radius	随机半径
	 * @param center	是否使用中心点
	 * @return
	 */
	public static Vector3f getRandomPosition(float radius, boolean center){
		if(center){
	        return new Vector3f(0.0f, 0.0f, 0.0f);
		}else{
			return getRandomPosition(radius);
		}
	}
}
